#pragma once

namespace mlg
{
	template<class Iterator,class Ref,class Ptr>
	class __list_reverse_iterator
	{
		typedef __list_reverse_iterator<Iterator, Ref, Ptr> self;
	public:
		__list_reverse_iterator(Iterator it)
			:_it(it)
		{}

		Ref operator*()
		{
			Iterator prev = _it;
			return *--prev;
		}

		Ptr operator->()
		{
			return &operator*();
		}
		//++it
		self& operator++()
		{
			--_it;
			return *this;
		}
		//it++
		self operator++(int)
		{
			self tmp(*this);
			_it--;
			return tmp;
		}
		//--it
		self& operator--()
		{
			++_it;
			return *this;
		}
		//it--
		self operator--(int)
		{
			self tmp(*this);
			_it++;
			return tmp;
		}

		bool operator!=(const self& rit)const
		{
			return _it != rit._it;
		}

		bool operator==(const self& rit)const
		{
			return _it == rit._it;
		}

	private:
		Iterator _it;
	};
}
